HAL USART state and error functions migration

This section provides information about the HAL USART state and error functions migration.

HAL_USRT_GetState

The function HAL_USART_GetState() remain unchanged.

HAL1

HAL2

HAL_USART_GetState(USART_HandleTypeDef *husart)
HAL_USART_GetState(const hal_usart_handle_t *husart)

Related concepts: Revised and optimized HAL state machine


HAL_USART_GetError

HAL1

HAL2

Description

In HAL1, the function HAL_USART_GetError() returns the USART error code. The USART error code can be a combination (bitfields) of the following values:

  • HAL_USART_ERROR_NONE

  • HAL_USART_ERROR_PE

  • HAL_USART_ERROR_NE

  • HAL_USART_ERROR_FE

  • HAL_USART_ERROR_ORE

  • HAL_USART_ERROR_RTO

  • HAL_USART_ERROR_UDR

  • HAL_USART_ERROR_DMA

  • /*

  • HAL_USART_ERROR_INVALID_CALLBACK

In HAL2, the function HAL_USART_GetLastErrorCodes() retrieves the last error codes for the USART. The USART last error codes can be a combination (bitfields) of the following values:

  • HAL_USART_ERROR_NONE

  • HAL_USART_RECEIVE_ERROR_PE

  • HAL_USART_RECEIVE_ERROR_NE

  • HAL_USART_RECEIVE_ERROR_FE

  • HAL_USART_RECEIVE_ERROR_ORE

  • HAL_USART_RECEIVE_ERROR_RTO

  • HAL_USART_TRANSMIT_ERROR_UDR

  • HAL_USART_RECEIVE_ERROR_DMA

  • HAL_USART_TRANSMIT_ERROR_DMA

Function name

HAL_USART_GetError(USART_HandleTypeDef *husart);
HAL_USART_GetLastErrorCodes(const hal_usart_handle_t *husart);

Note

In HAL2, the constant HAL_USART_ERROR_INVALID_CALLBACK has been removed. Instead, functions HAL_USART_RegisterXXXCallback() return HAL_INVALID_PARAM in case of an invalid callback pointer.

Related concepts: Revised and optimized HAL error management.